<html><head>

<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jsSO.js"></script>

<script type="text/javascript">

jsSO.connect('rtmp://pro-web.at/firstapp', {debug: true});

$(':button').live('click', function(){

	// call function
	jsSO.service.add(2, 4).addCallback(function(ret){
		console.log(ret); // 6
	});
	// call alternative
	jsSO.call('add', 2, 4).addCallback(function(ret){
		console.log(ret); // 6
	});
	
	// call unknown function
	jsSO.call('unknown').addCallback(function(ret){
		// we don't get here
		console.log('OK');
	}).addErrback(function(error){
		// error object is printed
		console.log(error);
		
		// error.application = "org.red5.server.service.MethodNotFoundException"
		// error.code = "NetConnection.Call.Failed"
		// error.description = "Method unknown without arguments not found"
		// error.level = "error"
	});

	// call a function, which throws an exception
	jsSO.service.throwException().addCallback(function(ret){
		// we don't get here, because the server java code throws an exception
		console.log('OK');
	}).addErrback(function(error){
		// error object is printed
		console.log(error);
		
		// error.application = "example.remoteapp.TestException" (the exception class)
		// error.code = "NetConnection.Call.Failed"
		// error.description = "some error occured" (the exception description)
		// error.level = "error"
	});
});

</script>

</head>
<body>
<form>
	<input type="button" value="test" />
	see your console-log for output
</form>
</body>
</html>
